﻿using _03_MVVM_数据绑定_命令绑定.Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace _03_MVVM_数据绑定_命令绑定.Converter
{
    class EnumToBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //Gender mode = (Gender)value;
            //return mode == (Gender)int.Parse(parameter.ToString());
            return (Gender)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(bool)value)
            {
                return null;
            }

            return (Gender)int.Parse(parameter.ToString());
        }
    }
}
